package com.example.ticketorder.repository;

import com.example.ticketorder.entity.Sales;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;
import java.sql.Date;
import java.sql.Time;
import java.util.List;

public interface SalesRepository extends CrudRepository<Sales,String> {
    @Query(nativeQuery = true,value = "SELECT  * FROM sales WHERE order_Number = ? and phone = ?")
    public Iterable<Sales> findSales(String order_Number, String phone);
    @Modifying
    @Transactional
    @Query(nativeQuery = true,value = "INSERT INTO sales VALUES (?,?,?,?,?,?,?,?)")
    public void insertSale(String order_Number, String phone, String car, String destination, Date date, Time timea,Time timeb, double money);
    @Modifying
    @Transactional
    //删除DELETE FROM 表名称 WHERE 列名称 = 值
    @Query(nativeQuery = true,value = "DELETE FROM sales WHERE order_Number = ? and phone = ?")
    public void deleteSale(String order_Number, String phone);
}
